//
//  NSObject+UITheme.m
//  FCHealthy
//
//  Created by mouxiaochun on 16/2/1.
//  Copyright © 2016年 mmc. All rights reserved.
//

#import "UITheme.h"
#define ColorWithRGB(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1.0]
#define ColorWithOne(R) [UIColor colorWithRed:R/255.0 green:R/255.0 blue:R/255.0 alpha:1.0]

@implementation UITheme


#pragma mark --  UIColor 相关
/**
 * 首页的灰色背景
 */
+ (UIColor *)homeGrayBGColor {

    return ColorWithRGB(249.0, 245.0, 245.0);
}

+ (UIColor *)tableViewGrayBGColor {
    return ColorWithRGB(236.0, 237.0, 238.0);

}

+ (UIColor *)grayTextColor{
    return ColorWithRGB(180, 180, 180);

}

//238,145,55
+ (UIColor *)orangeColor238 {

    return ColorWithRGB(238,145,55);
}
//字体颜色
+ (UIColor *)fontColor {
    return ColorWithRGB(50,50,50);
}

+ (UIColor *)logoBorderColor {
    //120 180 166
    return [UIColor colorWithRed:120/255.0 green:180/255.0 blue:166/255.0 alpha:1.0];
}

#pragma mark --- View相关

//向右的箭头
+ (UIImageView *)accessoryView {

    UIImage *image = [UIImage imageNamed:@"go_gray"];
    UIImageView *iv = [[UIImageView alloc] initWithImage:image];
    iv.frame = (CGRect){0,0,image.size};
    return iv;
}

//橘红色按钮
+ (UIButton *)orangeButton {
    return [UITheme btCreator: @"btn_link_active"];
}
//登录按钮
+ (UIButton *)loginButton {
    return [UITheme btCreator: @"login_btn"];

}

//上传身份证按钮
+ (UIButton *)uploadButton {
    return [UITheme btCreator: @"register_btn"];
    
}

//注册按钮
+ (UIButton *)registerButton {
    return [UITheme btCreator: @"btn_link1"];
}


+ (UIButton *)btCreator:(NSString *)btImageName
{
    UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *image = [UIImage imageNamed:btImageName];
    image = [image stretchableImageWithLeftCapWidth:4 topCapHeight:3];
    [bt setBackgroundImage:image forState:UIControlStateNormal];
    bt.frame = (CGRect){12,0,Screen.width - 24,40};
    [bt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    bt.titleLabel.font = [UIFont systemFontOfSize:16];
    return bt;
}


@end

@implementation NSObject (color)
//app主颜色－－－淡粉
- (UIColor *) appColor
{
    return ColorWithRGB(253, 243, 249);
}
//导航栏主颜色
- (UIColor *) navigatorColor
{
    return [UIColor whiteColor];
}
- (UIColor *) navigatorTitleColor
{
    return ColorWithRGB(15 , 138, 251);
    
}
- (UIColor *) lightGrayColor242
{
    return  ColorWithRGB(242, 243, 244);
}

- (UIColor *)whiteTransparent
{
    return [UIColor colorWithWhite:1.0f alpha:0.7f];
}
- (UIColor *) spaceColor238238238
{
    return ColorWithOne(238);
}

//我的健康标题颜色
- (UIColor *) titleColor161161161
{
    return ColorWithOne(161);
}

//我的健康副标题颜色
- (UIColor *) subTColor253092085
{
    return ColorWithRGB(233, 160, 123);
}
- (UIColor *)chartTitle100100100
{
    return ColorWithOne(100);
}

- (UIColor *) mengCeng236145055
{
    return ColorWithRGB(236, 145, 55);
}

//我的健康－－身高背景色
- (UIColor *) heightBGColor
{
    return ColorWithRGB(238, 221, 199);
}

- (UIColor *) heightBGColotRed
{
    return ColorWithRGB(237, 217, 211);
}
@end

@implementation NSObject (font)

- (UIFont *)fontSystem
{
    return [UIFont systemFontOfSize:[UIFont systemFontSize]];
}

- (UIFont *)fontSize11
{
    return [UIFont systemFontOfSize:11];
}
- (UIFont *)fontSize12
{
    return [UIFont systemFontOfSize:12];
}

- (UIFont *)fontSize13
{
    return [UIFont systemFontOfSize:13];
}

- (UIFont *)fontSize14
{
    return [UIFont systemFontOfSize:14];
}

- (UIFont *)fontSize18
{
    return [UIFont systemFontOfSize:18];
}


- (UIFont *)fontSize16
{
    return [UIFont systemFontOfSize:16];
}
- (UIFont *)fontSize17
{
    return [UIFont systemFontOfSize:17];
}

@end

@implementation NSString (att)

- (NSMutableAttributedString *) changeText:(NSString *)string forColor:(UIColor *)color 
{
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:self];
    NSRange range = [self rangeOfString:string];
    [str addAttribute:NSForegroundColorAttributeName value:color range:range];
    return str;
}

- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize
{
    NSDictionary *attrs = @{NSFontAttributeName : font};
    CGSize size =  [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attrs context:nil].size;
    return CGSizeMake(size.width+6,size.height);
}

@end